/*
 * Edge_Detect.c

 *
 *  Created on: 12/11/2013
 *      Author: Administrador
 */


#include "Mytypes.h"
#include "Edge_Detect.h"

 using namespace cv;
 using namespace std;


 //Values for Contrast and Brightnes
 double alpha_e = 2.3; 	//Contrast control [1.0 - 3.0]
 int beta_e = 50;		//Brightnes control [0 - 100]
 int Thresshold_min_e = 1;
 int Thresshold_max_e = Thresshold_min_e * 200;
 int Kernel_Size_e = 3;

 int Flag_Log_e;


 void Edge_Detect(void){

        Mat img_Bq = imread("lena.png",CV_LOAD_IMAGE_COLOR );

        if (img_Bq.empty()){
                cout << "Cannot load image!" << endl;
                Flag_Log_e = CAN_NOT_LOAD_IMAGE;
        }


        // Creamos un objeto tipo MAT para almacenar el nuevo valor
        Mat img_Bq_Gray,img_Bq_Gray_Edge;
        Mat img_Bq_Gray_Filter;

        //Convert to Gray
        cvtColor(img_Bq, img_Bq_Gray, CV_RGB2GRAY ); // Convert the image into Gray and anothers type of photos

        //Filter the image
        blur(img_Bq_Gray, img_Bq_Gray_Filter, Size(3,3) );
        //EDGE DETECTION.

        //Filter Image
        Canny(img_Bq_Gray_Filter, img_Bq_Gray_Edge, Thresshold_min_e, Thresshold_max_e, Kernel_Size_e);

        cv::FileStorage Storage("test2.xml",cv::FileStorage::WRITE);
        Storage << "img" << img_Bq_Gray_Filter;
        Storage.release();




        namedWindow("image", CV_WINDOW_AUTOSIZE);
        namedWindow("Edge Image", CV_WINDOW_AUTOSIZE);

        imshow("image", img_Bq);
        imshow("Edge Image",img_Bq_Gray_Edge);

        waitKey(0);

 }




